package com.lan.test02;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Test {
    public static void main(String[] args) throws IOException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
        //将prop.properties读到集合中
        Properties prop = new Properties();
        FileReader fr = new FileReader("day16_class\\prop.properties");
        prop.load(fr);

        //根据prop.properties的内容来执行对应类的方法
        Class clazz = Class.forName(getValue("ClassName",prop));
        Object o = clazz.newInstance();
        Method method = clazz.getMethod(getValue("MethodName",prop), Integer.class);
        Object invoke = method.invoke(o, 8);
        System.out.println(invoke);
    }

    private static String getValue(String name,Properties prop) {
        return prop.getProperty(name);
    }
}
